Neural Network Processor

ABSTRACT

A circuit for performing neural network computations for a neural network comprising a plurality of neural network layers, the circuit comprising: a matrix computation unit configured to, for each of the plurality of neural network layers: receive a plurality of weight inputs and a plurality of activation inputs for the neural network layer, and generate a plurality of accumulated values based on the plurality of weight inputs and the plurality of activation inputs; and a vector computation unit communicatively coupled to the matrix computation unit and configured to, for each of the plurality of neural network layers: apply an activation function to each accumulated value generated by the matrix computation unit to generate a plurality of activated values for the neural network layer.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. application Ser. No.16/529,782, filed Aug. 1, 2019, which is a continuation of U.S.application Ser. No. 15/686,615, filed on Aug. 25, 2017, which is acontinuation of U.S. application Ser. No. 14/844,524, filed on Sep. 3,2015, which is a non-provisional of and claims priority to U.S.Provisional Patent Application No. 62/164,931, filed on May 21, 2015,the entire contents of which are hereby incorporated by reference.

BACKGROUND

This specification relates to computing neural network inferences inhardware.

Neural networks are machine learning models that employ one or morelayers of models to generate an output, e.g., a classification, for areceived input. Some neural networks include one or more hidden layersin addition to an output layer. The output of each hidden layer is usedas input to the next layer in the network, i.e., the next hidden layeror the output layer of the network. Each layer of the network generatesan output from a received input in accordance with current values of arespective set of parameters.

SUMMARY

In general, this specification describes a special-purpose hardwarecircuit that computes neural network inferences.

In general, one innovative aspect of the subject matter described inthis specification can be embodied in a circuit for performing neuralnetwork computations for a neural network comprising a plurality ofneural network layers, the circuit comprising: a matrix computation unitconfigured to, for each of the plurality of neural network layers:receive a plurality of weight inputs and a plurality of activationinputs for the neural network layer, and generate a plurality ofaccumulated values based on the plurality of weight inputs and theplurality of activation inputs; and a vector computation unitcommunicatively coupled to the matrix computation unit and configuredto, for each of the plurality of neural network layers: apply anactivation function to each accumulated value generated by the matrixcomputation unit to generate a plurality of activated values for theneural network layer.

Implementations can include one or more of the following features. Aunified buffer communicatively coupled to the matrix computation unitand the vector computation unit, where the unified buffer is configuredto receive and store output from the vector computation unit, and theunified buffer is configured to send the received output as input to thematrix computation unit. A sequencer configured to receive instructionsfrom a host device and generate a plurality of control signals from theinstructions, where the plurality of control signals control dataflowthrough the circuit; and a direct memory access engine communicativelycoupled to the unified buffer and the sequencer, where the direct memoryaccess engine is configured to send the plurality of activation inputsto the unified buffer, where the unified buffer is configured to sendthe plurality of activation inputs to the matrix computation unit, andwhere the direct memory access engine is configured to read result datafrom the unified buffer. A memory unit configured to send the pluralityof weight inputs to the matrix computation unit, and where the directmemory access engine is configured to send the plurality of weightinputs to the memory unit. The matrix computation unit is configured asa two dimensional systolic array comprising a plurality of cells. Theplurality of weight inputs is shifted through a first plurality of cellsalong a first dimension of the systolic array, and where the pluralityof activation inputs is shifted through a second plurality of cellsalong a second dimension of the systolic array. For a given layer in theplurality of layers, a count of the plurality of activation inputs isgreater than a size of the second dimension of the systolic array, andwhere the systolic array is configured to: divide the plurality ofactivation inputs into portions, where each portion has a size less thanor equal to the size of the second dimension; generating, for eachportion, a respective portion of accumulated values; and combining eachportion of accumulated values to generate a vector of accumulated valuesfor the given layer. For a given layer in the plurality of layers, acount of the plurality of weight inputs is greater than a size of thefirst dimension of the systolic array, and where the systolic array isconfigured to: divide the plurality of weight inputs into portions,where each portion has a size less than or equal to the size of thefirst dimension; generating, for each portion, a respective portion ofaccumulated values; and combining each portion of accumulated values togenerate a vector of accumulated values for the given layer. Each cellin the plurality of cells comprises: a weight register configured tostore a weight input; an activation register configured to store anactivation input and configured to send the activation input to anotheractivation register in a first adjacent cell along the second dimension;a sum-in register configured to store a previously summed value;multiplication circuitry communicatively coupled to the weight registerand the activation register, where the multiplication circuitry isconfigured to output a product of the weight input and the activationinput; and summation circuitry communicatively coupled to themultiplication circuitry and the sum-in register, where the summationcircuitry is configured to output a sum of the product and thepreviously summed value, and where the summation circuitry is configuredto send the sum to another sum-in register in a second adjacent cellalong the first dimension. One or more cells in the plurality of cellsare each configured to store the respective sum in a respectiveaccumulator unit, where the respective sum is an accumulated value. Thefirst dimension of the systolic array corresponds to columns of thesystolic array, and where the second dimension of the systolic arraycorresponds to rows of the systolic array. The vector computation unitnormalizes each activated value to generate a plurality of normalizedvalues. The vector computation unit pools one or more activated valuesto generate a plurality of pooled values.

Particular embodiments of the subject matter described in thisspecification can be implemented so as to realize one or more of thefollowing advantages. Implementing a neural network processor inhardware improves efficiency, e.g., increase speed and throughput andreduce power and cost, over implementations in software. This can beuseful for inference applications. Integrating components of the neuralnetwork processor into one circuit allows inferences to be computedwithout incurring penalties of off-chip communication. Additionally, thecircuit can process neural network layers that have a number of inputs,e.g., a number of weight inputs or a number of activation inputs, largerthan a size of a dimension of a matrix computation unit within thecircuit. For example, the circuit can process a large number of weightinputs per neuron of the neural network.

The details of one or more embodiments of the subject matter of thisspecification are set forth in the accompanying drawings and thedescription below. Other features, aspects, and advantages of thesubject matter will become apparent from the description, the drawings,and the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a flow diagram of an example method for performing acomputation for a given layer of a neural network.

FIG. 2 shows an example neural network processing system.

FIG. 3 shows an example architecture including a matrix computationunit.

FIG. 4 shows an example architecture of a cell inside a systolic array.

FIG. 5 shows an example architecture of a vector computation unit.

FIG. 6 is a flow diagram of another example process for performing,using a systolic array, the computation for a given neural network layerhaving more activation inputs than rows in the systolic array.

Like reference numbers and designations in the various drawings indicatelike elements.

DETAILED DESCRIPTION

A neural network having multiple layers can be used to computeinferences. For example, given an input, the neural network can computean inference for the input. The neural network computes this inferenceby processing the input through each of the layers of the neuralnetwork. In particular, the layers of the neural network are arranged ina sequence, each with a respective set of weights. Each layer receivesan input and processes the input in accordance with the set of weightsfor the layer to generate an output.

Therefore, in order to compute an inference from a received input, theneural network receives the input and processes it through each of theneural network layers in the sequence to generate the inference, withthe output from one neural network layer being provided as input to thenext neural network layer. Data inputs to a neural network layer, e.g.,either the input to the neural network or the outputs of the layer belowthe layer in the sequence, to a neural network layer can be referred toas activation inputs to the layer.

In some implementations, the layers of the neural network are arrangedin a directed graph. That is, any particular layer can receive multipleinputs, multiple outputs, or both. The layers of the neural network canalso be arranged such that an output of a layer can be sent back as aninput to a previous layer.

FIG. 1 is a flow diagram of an example process 100 for performing acomputation for a given layer of a neural network using aspecial-purpose hardware circuit. For convenience, the method 100 willbe described with respect to a system having one or more circuits thatperforms the method 100. The method 100 can be performed for each layerof the neural network in order to compute an inference from a receivedinput.

The system receives sets of weight inputs (step 102) and sets ofactivation inputs (step 104) for the given layer. The sets of weightinputs and the sets of activation inputs can be received from dynamicmemory and a unified buffer, respectively, of the special-purposehardware circuit. In some implementations, both the sets of weightinputs and the sets of activation inputs can be received from theunified buffer.

The system generates accumulated values from the weight inputs and theactivation inputs using a matrix multiplication unit of thespecial-purpose hardware circuit (step 106). In some implementations,the accumulated values are dot products of the sets of weight inputs andthe sets of activation inputs. That is, for one set of weights, thesystem can multiply each weight input with each activation input and sumthe products together to form an accumulated value. The system can thencompute dot products of other set of weights with other sets ofactivation inputs.

The system can generate a layer output from the accumulation values(step 108) using a vector computation unit of the special-purposehardware circuit. In some implementations, the vector computation unitapplies an activation function to the accumulated values, which will bedescribed further below in reference to FIG. 5. The output of the layercan be stored in the unified buffer for use as an input to a subsequentlayer in the neural network or can be used to determine the inference.The system finishes processing the neural network when a received inputhas been processed through each layer of the neural network to generatethe inference for the received input.

FIG. 2 shows an example special-purpose integrated circuit 200 forperforming neural network computations. The system 200 includes a hostinterface 202. The host interface 202 can receive instructions thatinclude parameters for a neural network computation. The parameters caninclude at least one or more of the following: how many layers should beprocessed, corresponding sets of weight inputs for each layer of thelayer, an initial set of activation inputs, i.e., the input to theneural network from which the inference is to be computed, correspondinginput and output sizes of each layer, a stride value for the neuralnetwork computation, and a type of layer to be processed, e.g., aconvolutional layer or a fully connected layer.

The host interface 202 can send the instructions to a sequencer 206,which converts the instructions into low level control signals thatcontrol the circuit to perform the neural network computations. In someimplementations, the control signals regulate dataflow in the circuit,e.g., how the sets of weight inputs and the sets of activation inputsflow through the circuit. The sequencer 206 can send the control signalsto a unified buffer 208, a matrix computation unit 212, and a vectorcomputation unit 214. In some implementations, the sequencer 206 alsosends control signals to a direct memory access engine 204 and dynamicmemory 210. In some implementations, the sequencer 206 is a processorthat generates clock signals. The sequencer 206 can use timing of theclock signals to, at appropriate times, send the control signals to eachcomponent of the circuit 200. In some other implementations, the hostinterface 202 passes in a clock signal from an external processor.

The host interface 202 can send the sets of weight inputs and theinitial set of activation inputs to the direct memory access engine 204.The direct memory access engine 204 can store the sets of activationinputs at the unified buffer 208. In some implementations, the directmemory access stores the sets of weights to dynamic memory 210, whichcan be a memory unit. In some implementations, the dynamic memory islocated off of the circuit.

The unified buffer 208 is a memory buffer. It can be used to store theset of activation inputs from the direct memory access engine 204 andoutputs of the vector computation unit 214. The vector computation unitwill be described in more detail below with reference to FIG. 5. Thedirect memory access engine 204 can also read the outputs of the vectorcomputation unit 214 from the unified buffer 208.

The dynamic memory 210 and the unified buffer 208 can send the sets ofweight inputs and the sets of activation inputs, respectively, to thematrix computation unit 212. In some implementations, the matrixcomputation unit 212 is a two-dimensional systolic array. The matrixcomputation unit 212 can also be a one-dimensional systolic array orother circuitry that can perform mathematical operations, e.g.,multiplication and addition. In some implementations, the matrixcomputation unit 212 is a general purpose matrix processor.

The matrix computation unit 212 can process the weight inputs and theactivation inputs and provide a vector of outputs to the vectorcomputation unit 214. In some implementations, the matrix computationunit sends the vector of outputs to the unified buffer 208, which sendsthe vector of outputs to the vector computation unit 214. The vectorcomputation unit can process the vector of outputs and store a vector ofprocessed outputs to the unified buffer 208. The vector of processedoutputs can be used as activation inputs to the matrix computation unit212, e.g., for use in a subsequent layer in the neural network. Thematrix computation unit 212 and the vector computation unit 214 will bedescribed in more detail below with reference to FIG. 3 and FIG. 5,respectively.

FIG. 3 shows an example architecture 300 including a matrix computationunit. The matrix computation unit is a two-dimensional systolic array306. The two-dimensional systolic array 306 can be a square array. Thearray 306 includes multiple cells 304. In some implementations, a firstdimension 320 of the systolic array 306 corresponds to columns of cellsand a second dimension 322 of the systolic array 306 corresponds to rowsof cells. The systolic array can have more rows than columns, morecolumns than rows, or an equal number of columns and rows.

In the illustrated example, value loaders 302 send activation inputs torows of the array 306 and a weight fetcher interface 308 sends weightinputs to columns of the array 306. In some other implementations,however, activation inputs are transferred to the columns and weightinputs are transferred to the rows of the array 306.

The value loaders 302 can receive the activation inputs from a unifiedbuffer, e.g., the unified buffer 208 of FIG. 2. Each value loader cansend a corresponding activation input to a distinct left-most cell ofthe array 306. The left-most cell can be a cell along a left-most columnof the array 306. For example, value loader 312 can send an activationinput to cell 314. The value loader can also send the activation inputto an adjacent value loader, and the activation input can be used atanother left-most cell of the array 306. This allows activation inputsto be shifted for use in another particular cell of the array 306.

The weight fetcher interface 308 can receive the weight input from amemory unit, e.g., the dynamic memory 210 of FIG. 2. The weight fetcherinterface 308 can send a corresponding weight input to a distincttop-most cell of the array 306. The top-most cell can be a cell along atop-most row of the array 306. For example, the weight fetcher interface308 can send weight inputs to cells 314 and 316.

In some implementations, a host interface, e.g., the host interface 202of FIG. 2, shifts activation inputs throughout the array 306 along onedimension, e.g., to the right, while shifting weight inputs throughoutthe array 306 along another dimension, e.g., to the bottom. For example,over one clock cycle, the activation input at cell 314 can shift to anactivation register in cell 316, which is to the right of cell 314.Similarly, the weight input at cell 316 can shift to a weight registerat cell 318, which is below cell 314.

On each clock cycle, each cell can process a given weight input and agiven activation input to generate an accumulated output. Theaccumulated output can also be passed to an adjacent cell along the samedimension as the given weight input. An individual cell is describedfurther below with reference FIG. 4.

The accumulated output can be passed along the same column as the weightinput, e.g., towards the bottom of the column in the array 306. In someimplementations, at the bottom of each column, the array 306 can includeaccumulator units 310 that store and accumulate each accumulated outputfrom each column when performing calculations with layers having moreweight inputs than columns or layers having more activation inputs thanrows. In some implementations, each accumulator unit stores multipleparallel accumulations. This will be described further below withreference to FIG. 6. The accumulator units 310 can accumulate eachaccumulated output to generate a final accumulated value. The finalaccumulated value can be transferred to a vector computation unit, e.g.,the vector computation unit 502 of FIG. 5. In some otherimplementations, the accumulator units 310 passes the accumulated valuesto the vector computation unit without performing any accumulations whenprocessing layers with fewer weight inputs than columns or layers havingfewer activating inputs than rows.

FIG. 4 shows an example architecture 400 of a cell inside a systolicarray, e.g., the systolic array 306 of FIG. 3.

The cell can include an activation register 406 that stores anactivation input. The activation register can receive the activationinput from a left adjacent cell, i.e., an adjacent cell located to theleft of the given cell, or from a unified buffer, depending on theposition of the cell within the systolic array. The cell can include aweight register 402 that stores a weight input. The weight input can betransferred from a top adjacent cell or from a weight fetcher interface,depending on the position of the cell within the systolic array. Thecell can also include a sum in register 404. The sum in register 404 canstore an accumulated value from the top adjacent cell. Multiplicationcircuitry 408 can be used to multiply the weight input from the weightregister 402 with the activation input from the activation register 406.The multiplication circuitry 408 can output the product to summationcircuitry 410.

The summation circuitry can sum the product and the accumulated valuefrom the sum in register 404 to generate a new accumulated value. Thesummation circuitry 410 can then send the new accumulated value toanother sum in register located in a bottom adjacent cell. The newaccumulated value can be used as an operand for a summation in thebottom adjacent cell.

The cell can also shift the weight input and the activation input toadjacent cells for processing. For example, the weight register 402 cansend the weight input to another weight register in the bottom adjacentcell. The activation register 406 can send the activation input toanother activation register in the right adjacent cell. Both the weightinput and the activation input can therefore be reused by other cells inthe array at a subsequent clock cycle.

In some implementations, the cell also includes a control register. Thecontrol register can store a control signal that determines whether thecell should shift either the weight input or the activation input toadjacent cells. In some implementations, shifting the weight input orthe activation input takes one or more clock cycles. The control signalcan also determine whether the activation input or weight inputs aretransferred to the multiplication circuitry 408, or can determinewhether the multiplication circuitry 408 operates on the activation andweight inputs. The control signal can also be passed to one or moreadjacent cells, e.g., using a wire.

In some implementations, weights are pre-shifted into a weight pathregister 412. The weight path register 412 can receive the weight input,e.g., from a top adjacent cell, and transfer the weight input to theweight register 402 based on the control signal. The weight register 402can statically store the weight input such that as activation inputs aretransferred to the cell, e.g., through the activation register 406, overmultiple clock cycles, the weight input remains within the cell and isnot transferred to an adjacent cell. Therefore, the weight input can beapplied to multiple activation inputs, e.g., using the multiplicationcircuitry 408, and respective accumulated values can be transferred toan adjacent cell.

FIG. 5 shows an example architecture 500 of a vector computation unit502. The vector computation unit 502 can receive a vector of accumulatedvalues from a matrix computation unit, e.g., the matrix computation unitdescribed in reference to FIG. 2.

The vector computation unit 502 can process the vector of accumulatedvalues at the activation unit 504. In some implementations, theactivation unit includes circuitry that applies a non-linear function toeach accumulated value to generate activation values. For example, thenon-linear function can be tanh(x), where x is an accumulated value.

Optionally, the vector computation unit 502 can normalize the activationvalues in a normalization unit 506 that generates normalized values fromthe activation values.

Also optionally, the vector computation unit 502 can pool values, eitheractivation values or normalization values, using a pooling unit 508. Thepooling unit 508 can apply an aggregation function to one or more of thenormalized values to generate pooled values. In some implementations,the aggregation functions are functions that return a maximum, minimum,or average of the normalized values or of a subset of the normalizedvalues.

Control signals 510 can be transferred, e.g., by the sequencer 206 ofFIG. 2, and can regulate how the vector computation unit 502 processesthe vector of accumulated values. That is, the control signals 510 canregulate whether the activation values are pooled, normalized, or both.The control signals 510 can also specify the activation, normalization,or pooling functions, as well as other parameters for normalization andpooling, e.g., a stride value.

The vector computation unit 502 can send values, e.g., activationvalues, normalized values, or pooled values, to a unified buffer, e.g.,the unified buffer 208 of FIG. 2.

In some implementations, the pooling unit 508 receives the activationvalues instead of the normalization unit 506, and the pooling unit 508sends the pooled values to the normalization unit 506, which generatesnormalized values to be stored in the unified buffer.

FIG. 6 is a flow diagram of example process for performing, using asystolic array, the computation for a given neural network layer havingmore activation inputs than rows in the systolic array. For convenience,the process 600 will be described with respect to a system that performsthe process 600. In some implementations, a host interface or asequencer performs the process 600, e.g., the host interface 202 or thesequencer 206, respectively, of FIG. 2. In some other implementations,the host interface receives instructions from an external processor thatperforms the process 600.

As described above, each layer can have multiple sets of activationinputs and each set of weight inputs can be transferred to cells atdistinct rows of the array. In some implementations, some layers of theneural network have more sets of activation inputs than there are rowsof the array.

The system can determine, e.g., using a comparator, whether there aremore sets of activation inputs for the given neural network layer thanthere are rows in the systolic array. In some implementations, thesystem makes the determination at compile time. A set of activationinputs can correspond to the activation inputs provided to a single rowof the array.

If there are more rows than sets of activation inputs (step 602), thesystem can generate accumulated values as described above in thesystolic array 306 of FIG. 3 (step 604).

If there are more sets of activation inputs to be processed than thereare rows in the array (step 602), the system can divide the sets ofactivation inputs into portions so that each portion has a size lessthan or equal to a number of rows in the array (step 606).

The system then can generate, for each portion of activation inputs, aportion of accumulated values (step 608). An accumulated value can be asum of products of activation and weight inputs to cells along a givencolumn, e.g., as described in systolic array 306 of FIG. 3. Each portionof accumulated values can be stored in a buffer until all portions ofactivation inputs have been processed. The buffer can be a buffer inaccumulator units 310 of FIG. 3, a buffer in the systolic array, or theunified buffer 208 of FIG. 2.

The system can then combine all portions of accumulated values into avector of accumulated values (step 610). In particular, the system canaccess the buffer of previously stored portions of accumulated valuesand accumulate, e.g., using accumulator units 310 of FIG. 3, theaccumulated values to generate a vector of the accumulated values. Thesystem can send the vector of the accumulated values to a vectorcomputation unit, e.g., the vector computation unit 214 of FIG. 2.

For example, if there are 256 rows in the array and there are 300 setsof activation inputs to process at a given layer, the system cangenerate 256 final accumulated values from 256 sets of activation inputsfor complete utilization of the systolic array and store the 256 finalaccumulated values in a buffer. The system can then generate 44 finalaccumulated values from the 44 remainder sets of activation inputs.Finally, the system can combine all 300 final accumulated values to forma vector and send the vector to the vector computation unit.

If there are more sets of weight inputs than columns to the array, thesystem can perform similar operations. That is, the system can dividethe sets of weight inputs into portions having fewer sets of weightinputs than a number of columns in the array, generate accumulatedvalues for each portion, and combine the accumulated values into avector for use in the vector computation unit. In some implementations,instead of comparing the number of sets of weight inputs with the numberof columns in the array, the system can compare the number ofaccumulated values with the number of columns in the array.

Although the system has been described with weight inputs beingtransferred to columns of the array and activation inputs beingtransferred to rows of the array, in some implementations, the weightinputs are transferred to rows of the array and the activation inputsare transferred to columns of the array.

Although the hardware is described to be for computing inferences, thehardware can be used for one or more of the following: convolutional orfully-connected neural network training, linear or logistic regression,clustering, e.g., k-means clustering, video-encoding, and imageprocessing.

Embodiments of the subject matter and the functional operationsdescribed in this specification can be implemented in digital electroniccircuitry, in tangibly-embodied computer software or firmware, incomputer hardware, including the structures disclosed in thisspecification and their structural equivalents, or in combinations ofone or more of them. Embodiments of the subject matter described in thisspecification can be implemented as one or more computer programs, i.e.,one or more modules of computer program instructions encoded on atangible non transitory program carrier for execution by, or to controlthe operation of, data processing apparatus. Alternatively or inaddition, the program instructions can be encoded on an artificiallygenerated propagated signal, e.g., a machine-generated electrical,optical, or electromagnetic signal, that is generated to encodeinformation for transmission to suitable receiver apparatus forexecution by a data processing apparatus. The computer storage mediumcan be a machine-readable storage device, a machine-readable storagesubstrate, a random or serial access memory device, or a combination ofone or more of them.

The term “data processing apparatus” encompasses all kinds of apparatus,devices, and machines for processing data, including by way of example aprogrammable processor, a computer, or multiple processors or computers.The apparatus can include special purpose logic circuitry, e.g., an FPGA(field programmable gate array) or an ASIC (application specificintegrated circuit). The apparatus can also include, in addition tohardware, code that creates an execution environment for the computerprogram in question, e.g., code that constitutes processor firmware, aprotocol stack, a database management system, an operating system, or acombination of one or more of them.

A computer program (which may also be referred to or described as aprogram, software, a software application, a module, a software module,a script, or code) can be written in any form of programming language,including compiled or interpreted languages, or declarative orprocedural languages, and it can be deployed in any form, including as astandalone program or as a module, component, subroutine, or other unitsuitable for use in a computing environment. A computer program may, butneed not, correspond to a file in a file system. A program can be storedin a portion of a file that holds other programs or data, e.g., one ormore scripts stored in a markup language document, in a single filededicated to the program in question, or in multiple coordinated files,e.g., files that store one or more modules, sub programs, or portions ofcode. A computer program can be deployed to be executed on one computeror on multiple computers that are located at one site or distributedacross multiple sites and interconnected by a communication network.

The processes and logic flows described in this specification can beperformed by one or more programmable computers executing one or morecomputer programs to perform functions by operating on input data andgenerating output. The processes and logic flows can also be performedby, and apparatus can also be implemented as, special purpose logiccircuitry, e.g., an FPGA (field programmable gate array) or an ASIC(application specific integrated circuit).

Computers suitable for the execution of a computer program include, byway of example, can be based on general or special purposemicroprocessors or both, or any other kind of central processing unit.Generally, a central processing unit will receive instructions and datafrom a read only memory or a random access memory or both. The essentialelements of a computer are a central processing unit for performing orexecuting instructions and one or more memory devices for storinginstructions and data. Generally, a computer will also include, or beoperatively coupled to receive data from or transfer data to, or both,one or more mass storage devices for storing data, e.g., magnetic,magneto optical disks, or optical disks. However, a computer need nothave such devices. Moreover, a computer can be embedded in anotherdevice, e.g., a mobile telephone, a personal digital assistant (PDA), amobile audio or video player, a game console, a Global PositioningSystem (GPS) receiver, or a portable storage device, e.g., a universalserial bus (USB) flash drive, to name just a few.

Computer readable media suitable for storing computer programinstructions and data include all forms of nonvolatile memory, media andmemory devices, including by way of example semiconductor memorydevices, e.g., EPROM, EEPROM, and flash memory devices; magnetic disks,e.g., internal hard disks or removable disks; magneto optical disks; andCD ROM and DVD-ROM disks. The processor and the memory can besupplemented by, or incorporated in, special purpose logic circuitry.

To send for interaction with a user, embodiments of the subject matterdescribed in this specification can be implemented on a computer havinga display device, e.g., a CRT (cathode ray tube) or LCD (liquid crystaldisplay) monitor, for displaying information to the user and a keyboardand a pointing device, e.g., a mouse or a trackball, by which the usercan send input to the computer. Other kinds of devices can be used tosend for interaction with a user as well; for example, feedback providedto the user can be any form of sensory feedback, e.g., visual feedback,auditory feedback, or tactile feedback; and input from the user can bereceived in any form, including acoustic, speech, or tactile input. Inaddition, a computer can interact with a user by sending documents toand receiving documents from a device that is used by the user; forexample, by sending web pages to a web browser on a user's client devicein response to requests received from the web browser.

Embodiments of the subject matter described in this specification can beimplemented in a computing system that includes a back end component,e.g., as a data server, or that includes a middleware component, e.g.,an application server, or that includes a front end component, e.g., aclient computer having a graphical user interface or a Web browserthrough which a user can interact with an implementation of the subjectmatter described in this specification, or any combination of one ormore such back end, middleware, or front end components. The componentsof the system can be interconnected by any form or medium of digitaldata communication, e.g., a communication network. Examples ofcommunication networks include a local area network (“LAN”) and a widearea network (“WAN”), e.g., the Internet.

The computing system can include clients and servers. A client andserver are generally remote from each other and typically interactthrough a communication network. The relationship of client and serverarises by virtue of computer programs running on the respectivecomputers and having a client-server relationship to each other.

While this specification contains many specific implementation details,these should not be construed as limitations on the scope of anyinvention or of what may be claimed, but rather as descriptions offeatures that may be specific to particular embodiments of particularinventions. Certain features that are described in this specification inthe context of separate embodiments can also be implemented incombination in a single embodiment. Conversely, various features thatare described in the context of a single embodiment can also beimplemented in multiple embodiments separately or in any suitablesubcombination. Moreover, although features may be described above asacting in certain combinations and even initially claimed as such, oneor more features from a claimed combination can in some cases be excisedfrom the combination, and the claimed combination may be directed to asubcombination or variation of a subcombination.

Similarly, while operations are depicted in the drawings in a particularorder, this should not be understood as requiring that such operationsbe performed in the particular order shown or in sequential order, orthat all illustrated operations be performed, to achieve desirableresults. In certain circumstances, multitasking and parallel processingmay be advantageous. Moreover, the separation of various system modulesand components in the embodiments described above should not beunderstood as requiring such separation in all embodiments, and itshould be understood that the described program components and systemscan generally be integrated together in a single software product orpackaged into multiple software products.

Particular embodiments of the subject matter have been described. Otherembodiments are within the scope of the following claims. For example,the actions recited in the claims can be performed in a different orderand still achieve desirable results. As one example, the processesdepicted in the accompanying figures do not necessarily require theparticular order shown, or sequential order, to achieve desirableresults. In certain implementations, multitasking and parallelprocessing may be advantageous.

What is claimed is:
 1. (canceled)
 2. A circuit for performing neuralnetwork computations for a neural network comprising a plurality ofneural network layers, the circuit comprising: a matrix computation unitconfigured to compute multiplications using a plurality of cells of thematrix computation unit to generate accumulated values, wherein each ofthe multiplications is between a weight for a neural network layer andan input to the neural network layer; and a vector computation unitconfigured to (i) generate a plurality of activated values for theneural network layer based on the accumulated values generated by thematrix computation unit and (ii) generate an output for the neuralnetwork layer based on the plurality of activated values.
 3. The circuitof claim 2, wherein: the matrix computation unit is configured as amulti-dimensional systolic array; and the plurality of cells arearranged along at least a first dimension and a second dimension of thesystolic array, the first dimension being different than the seconddimension.
 4. The circuit of claim 3, wherein the matrix computationunit is configured to: load one or more weights for the neural networklayer into the plurality of cells of the matrix computation unit; andshift one or more weights through the plurality of cells of the matrixcomputation unit.
 5. The circuit of claim 4, wherein the matrixcomputation unit is configured to: shift one or more inputs for theneural network layer into the plurality of cells of the matrixcomputation unit to perform the multiplications between the weight forthe neural network layer and the input to the neural network layer. 6.The circuit of claim 4, wherein the vector computation unit isconfigured to: apply an activation function to each of the accumulatedvalues provided by the matrix computation unit; and generate theplurality of activated values for the neural network layer based on theactivation function that is applied to each of the accumulated values.7. The circuit of claim 4, wherein each activated value of the pluralityof activated values represents an activation input to a second neuralnetwork layer and the matrix computation unit is configured to: shiftone or more weights for the second neural network layer through a firstplurality of cells of the systolic array along a first, column dimensionof the systolic array; and shift a plurality of activation inputs to thesecond neural network layer through a second plurality of cells of thesystolic array along a second, row dimension of the systolic array. 8.The circuit of claim 7, wherein the matrix computation unit isconfigured to: generate a vector of accumulated values for the secondneural network layer based on dot products of multiplications betweenthe one or more weights for the second neural network layer anddifferent activation inputs to the second neural network layer that areshifted along the second, row dimension of the of the systolic array. 9.The circuit of claim 8, wherein the vector computation unit isconfigured to: receive the vector of accumulated values generated by thematrix computation unit; and generate a vector of activation values inresponse to applying an activation function to each accumulated value inthe vector of accumulated values.
 10. The circuit of claim 2, wherein:the matrix computation unit is configured as a multi-dimensionalsystolic array; the systolic array includes the plurality of cells beingarranged along at least a first dimension of the systolic array and asecond dimension of the systolic array; and the first dimension and thesecond dimension are the same dimension.
 11. A method for performingneural network computations using a circuit configured to implement aneural network comprising a plurality of neural network layers, themethod comprising: receiving, by a matrix computation unit in thecircuit, a plurality of weights for a neural network layer and inputs tothe neural network layer; computing, using a plurality of cells of amatrix computation unit, multiplications between a weight for the neuralnetwork layer and one or more of the inputs to the neural network layer;and generating, using activation circuity of a vector computation unitin the circuit, an output for the neural network layer based on themultiplications.
 12. The method of claim 11, wherein generating theoutput for the neural network layer comprises: generating, by the matrixcomputation unit, accumulated values for the neural network layer basedon the multiplications; and generating, by the vector computation unit,a plurality of activated values for the neural network layer based onthe accumulated values generated by the matrix computation unit.
 13. Themethod of claim 12, wherein computing the multiplications between theweight for the neural network layer and one or more of the inputscomprises: computing the multiplications using a multi-dimensionalsystolic array of the matrix computation unit, and wherein the pluralityof cells are arranged along at least a first dimension and a seconddimension of the systolic array, the first dimension being differentthan the second dimension.
 14. The method of claim 13, wherein receivingthe plurality of weights for the neural network layer comprises: loadingone or more weights for the neural network layer into a distinct cell ofthe plurality of cells of the matrix computation unit; and shifting oneor more weights through one or more cells of the plurality of cells ofthe matrix computation unit.
 15. The method of claim 14, whereinreceiving the inputs to the neural network layer comprises: shifting oneor more inputs for the neural network layer into the distinct cell ofthe plurality of cells of the matrix computation unit to perform themultiplications between the weight for the neural network layer and oneor more of the inputs to the neural network layer.
 16. The method ofclaim 12, wherein generating the plurality of activated values for theneural network layer comprises: applying, by the activation circuity ofthe vector computation unit, an activation function to each of theaccumulated values generated by the matrix computation unit; andgenerating the plurality of activated values for the neural networklayer based on the activation function applied to each of theaccumulated values.
 17. The method of claim 16, comprising: receiving,by the vector computation unit, a vector of accumulated values generatedby the matrix computation unit; and generating, by the vectorcomputation unit, a vector of activation values in response to applyingthe activation function to each accumulated value in the vector ofaccumulated values.
 18. The method of claim 13, wherein each activatedvalue of the plurality of activated values represents an activationinput to a second neural network layer and the method comprises:shifting one or more weights for the second neural network layer througha first plurality of cells of the systolic array along a first, columndimension of the systolic array; and shifting a plurality of activationinputs to the second neural network layer through a second plurality ofcells of the systolic array along a second, row dimension of thesystolic array.
 19. The method of claim 18, comprising: generating avector of accumulated values for the second neural network layer basedon dot products of multiplications between the one or more weights forthe second neural network layer and different activation inputs providedto the second neural network layer that are shifted along the second,row dimension of the of the systolic array.
 20. The method of claim 12,wherein: the matrix computation unit is configured as amulti-dimensional systolic array; the systolic array includes theplurality of cells being arranged along at least a first dimension ofthe systolic array and a second dimension of the systolic array; and thefirst dimension and the second dimension are the same dimension.
 21. Oneor more non-transitory machine-readable storage devices for storinginstructions that are executable by one or more processing devices tocause performance of operations for performing neural networkcomputations using a circuit configured to implement a neural networkcomprising a plurality of neural network layers, the operationscomprising: receiving, by a matrix computation unit in the circuit, aplurality of weights for a neural network layer and inputs to the neuralnetwork layer; computing, using a plurality of cells of the matrixcomputation unit, multiplications between a weight for the neuralnetwork layer and one or more of the inputs to the neural network layer;and generating, using activation circuity of a vector computation unitin the circuit, an output for the neural network layer based on themultiplications.